#!/bin/bash -e
#
# Copyright 2018-present The Material Components for iOS Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Apply themer templates to every component
find components -type d | grep ColorThemer | sort | uniq | while read line; do
  component=$(echo "$line" | cut -d'/' -f2)
  themer=$(echo "$line" | cut -d'/' -f4)
  
  echo "Generating color theming documentation for $component..."

  ./scripts/apply_template $component scripts/templates/component/docs/color-theming.md.template components/$component/docs/color-theming.md
done

find components -type d | grep ShapeThemer | sort | uniq | while read line; do
  component=$(echo "$line" | cut -d'/' -f2)
  themer=$(echo "$line" | cut -d'/' -f4)

  echo "Generating shape theming documentation for $component..."

  ./scripts/apply_template $component scripts/templates/component/docs/shape-theming.md.template components/$component/docs/shape-theming.md
done

find components -type d | grep TypographyThemer | sort | uniq | while read line; do
  component=$(echo "$line" | cut -d'/' -f2)
  themer=$(echo "$line" | cut -d'/' -f4)
  
  echo "Generating typography theming documentation for $component..."

  ./scripts/apply_template $component scripts/templates/component/docs/typography-theming.md.template components/$component/docs/typography-theming.md
done
